<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Microsoft SQL Server Functions (PDO_SQLSRV)</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ref.pdo-mysql.connection.html">« PDO_MYSQL DSN</a></li>
      <li style="float: right;"><a href="ref.pdo-sqlsrv.connection.html">PDO_SQLSRV DSN »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="pdo.drivers.html">PDO 驱动</a></li>
    <li>Microsoft SQL Server Functions (PDO_SQLSRV)</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="ref.pdo-sqlsrv" class="reference">
 
  <h1 class="title">Microsoft SQL Server Functions (PDO_SQLSRV)</h1>
  
  <div class="partintro">

   <div class="section" id="pdo-sqlsrv.intro">
   <h2 class="title">简介</h2>
    <p class="para">
     PDO_SQLSRV is a driver that implements the <a href="intro.pdo.html" class="link">PHP
     Data Objects (PDO) interface</a>
     to enable access from PHP to MS SQL Server (starting with SQL Server 2005) 
     and SQL Azure databases.
    </p>
   </div>
   

<div class="section" id="ref.pdo-sqlsrv.installation">
 <h2 class="title">安装</h2>
 <p class="para">
  The most recent version of the driver is available for download here:
  <a href="http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx" class="link external">&raquo;&nbsp;SQLSRV download</a>.
  The driver sources are hosted in a <a href="https://github.com/microsoft/msphpsql" class="link external">&raquo;&nbsp;public repository</a>.
 </p>
 <p class="para">
  For more information about system requirements, see 
  <a href="http://msdn.microsoft.com/en-us/library/cc296170.aspx" class="link external">&raquo;&nbsp;SQLSRV System Requirements</a>.
 </p>
 <p class="para">
  On Windows the PDO_SQLSRV extension is enabled by downloading and adding appropriate DLL files to your PHP
  extension directory and the corresponding entry to the <var class="filename">php.ini</var> file.
 </p>
 <p class="para">
  On Linux and macOS, the PDO_SQLSRV extension can be installed using <a href="https://pecl.php.net/" class="link external">&raquo;&nbsp;PECL</a>.
  See the <a href="https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac" class="link external">&raquo;&nbsp;installation tutorial</a> for details.
 </p>
</div>



   

<div class="section" id="pdo-sqlsrv.constants">
 <h2 class="title">预定义常量</h2>
 <p class="simpara">下列常量由此驱动定义，且仅在扩展编译入 PHP
或在运行时动态载入时可用。另外，使用此驱动时，仅会使用这些驱动特定的常量。使用其他驱动的驱动特定的常量可能会导致不可预见的情况。如果代码可运行于多个驱动，<span class="function"><a href="pdo.getattribute.html" class="function">PDO::getAttribute()</a></span>
可被用于获取
<strong><code>PDO_ATTR_DRIVER_NAME</code></strong>
属性以检查驱动。</p>
 <dl>
  
   <dt id="pdo.constants.sqlsrv-txn-read-uncommitted">
    <strong><code>PDO::SQLSRV_TXN_READ_UNCOMMITTED</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Read Uncommitted.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-read-committed">
    <strong><code>PDO::SQLSRV_TXN_READ_COMMITTED</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Read Committed.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-repeatable-read">
    <strong><code>PDO::SQLSRV_TXN_REPEATABLE_READ</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Repeateable Read.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-snapshot">
    <strong><code>PDO::SQLSRV_TXN_SNAPSHOT</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to Snapshot.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-txn-serializable">
    <strong><code>PDO::SQLSRV_TXN_SERIALIZABLE</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     This constant is an acceptable value for the SQLSRV DSN key TransactionIsolation. 
     This constant sets the transaction isolation level for the connection to 
     Serializable.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-binary">
    <strong><code>PDO::SQLSRV_ENCODING_BINARY</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved as a raw byte stream to/from the server 
     without performing encoding or translation. This constant can be passed to 
     PDOStatement::setAttribute, PDO::prepare, PDOStatement::bindColumn, and 
     PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-system">
    <strong><code>PDO::SQLSRV_ENCODING_SYSTEM</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server as 8-bit characters 
     as specified in the code page of the Windows locale that is set on the system. 
     Any multi-byte characters or characters that do not map into this code page 
     are substituted with a single byte question mark (?) character. This constant 
     can be passed to PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-utf8">
    <strong><code>PDO::SQLSRV_ENCODING_UTF8</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server in UTF-8 encoding. 
     This is the default encoding. This constant can be passed to 
     PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-encoding-default">
    <strong><code>PDO::SQLSRV_ENCODING_DEFAULT</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     Specifies that data is sent/retrieved to/from the server according to 
     PDO::SQLSRV_ENCODING_SYSTEM if specified during connection. The connection&#039;s 
     encoding is used if specified in a prepare statement. This constant can be 
     passed to PDOStatement::setAttribute, PDO::setAttribute, PDO::prepare, 
     PDOStatement::bindColumn, and PDOStatement::bindParam.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-attr-query-timeout">
    <strong><code>PDO::SQLSRV_ATTR_QUERY_TIMEOUT</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     A non-negative integer representing the timeout period, in seconds. Zero (0) 
     is the default and means no timeout. This constant can be passed to 
     PDOStatement::setAttribute, PDO::setAttribute, and PDO::prepare.
    </span>
   </dd>

  
  
   <dt id="pdo.constants.sqlsrv-attr-direct-query">
    <strong><code>PDO::SQLSRV_ATTR_DIRECT_QUERY</code></strong>
     (<span class="type">int</span>)
   </dt>

   <dd>

    <span class="simpara">
     Indicates that a query should be executed directly, without being prepared. 
     This constant can be passed to PDO::setAttribute, and PDO::prepare. For more 
     information, see 
     <a href="http://msdn.microsoft.com/en-us/library/ff754356.aspx" class="link external">&raquo;&nbsp;Direct and Prepared Statement Execution</a>.
    </span>
   </dd>

  
 </dl>

</div>



  </div>

  

 <h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-sqlsrv.connection.html">PDO_SQLSRV DSN</a> — Connecting to MS SQL Server and SQL Azure databases</li></ul>
</div>
</div></div></body></html>